#include <iostream>
using namespace std;

// 求和，前提：传入参数必须能够相加，C++17
template <typename T1, typename... T2>
auto Sum(T1 a, T2... b) {
  return (a + ... + b);
}

// 求和，前提：传入参数必须能够相加，C++14
template <typename T>
auto Sum2(T a) {
  return a;
}
template <typename T1, typename... T2>
auto Sum2(T1 a, T2... b) {
  return a + Sum2(b...);
}
// 逗号展开参数包，
int main() {
  cout << Sum(0.1, 0.2, 0.3, 0.4) << endl;
  cout << Sum(1, 2, 3, 4) << endl;
  cout << Sum(3.1, 1, 0.9, 5) << endl;
  cout << Sum2(0.1, 0.2, 0.3, 0.4) << endl;
  cout << Sum2(1, 2, 3, 4) << endl;
  cout << Sum2(3.1, 1, 0.9, 5) << endl;
}